package com.yc.configure;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 跨域映射配置
 */
@Configuration
public class CorsConfig implements WebMvcConfigurer {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOriginPatterns("*") // 允许所有来源（生产环境应限制为具体域名）
                .allowedMethods("GET", "HEAD","POST", "PUT", "DELETE","OPTIONS")
                .allowCredentials(true)
                .allowedHeaders("*");
    }
}
